package cate.game.role.pvp.throne.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBTB;
import cate.game.pvp.throne.data.ko.TBKoAdvanceGroup;
import cate.game.pvp.throne.data.ko.TBKoRound;
import cate.game.pvp.throne.dto.TBGroupDataDTO;
import easy.java.dev.note.NoteField;

import java.util.List;
import java.util.stream.Collectors;

@ClientMsg(title = "晋级赛数据 の 请求")
public class TBKoAdvanceReq implements MsgInput {

    @NoteField("等级组")
    public int group;

    @NoteField(value = "分组类型",detail = "1胜者组 2败者组")
    public int groupType;

    @NoteField(value = "回合数",detail = "具体要请求哪些回合的数据")
    public List<Integer> rounds;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        TBGroupDataDTO groupData = game.pvp.throne.data.holder.groupMap.get(group);
        TBKoAdvanceGroup advanceGroup = groupData.ko.advance.groups.get(groupType);
        List<TBKoRound> roundInfos = advanceGroup.rounds.stream().filter(r -> this.rounds.contains(r.round)).collect(Collectors.toList());
        cc.getRole().sendNow(new TBKoAdvanceResp(group, groupType, roundInfos));
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBTB.KO_ADVANCE_REQ;
    }
}
